<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2017/5/3
  Time: 10:13
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/res/bootstrap.min.css" type="text/css" />
    <link rel="stylesheet" href="${pageContext.request.contextPath}/res/bootstrap-theme.css" type="text/css" />
    <link rel="stylesheet" href="${pageContext.request.contextPath}/res/style2.css" type="text/css" />

    <style type="text/css">
        .form{text-align: center;padding: 10px 0;}
    </style>
</head>
<body>
    <form role="form" id="form" class="form-inline form" action="#">
        <div class="form-group">

            <div class="input-group">
                <span class="input-group-addon">年份：</span>
                <select class="form-control"  name="year"  id="year" style="width:100px">
                    <option value="2017" selected="selected">2017</option>
                    <option value="2016">2016</option>
                </select>
            </div>

            <div class="input-group">
                <span class="input-group-addon">月份：</span>
                <select class="form-control"  name="month"  id="month" style="width:100px">

                    <option value="1" selected="selected">1</option>
                    <option value="1">2</option>
                    <option value="1">3</option>
                    <option value="1">4</option>
                    <option value="1">5</option>

                </select>
            </div>

            <input type="submit" class="btn btn-primary" value="查询">

            <button name="btn_query"  class="btn btn-primary"
                    type="button"  onclick="export1()">导出数据
            </button>

            <button name="btn_query"  class="btn btn-info" type="button"  onclick="export_record()">
                <span class="glyphicon glyphicon-circle-arrow-down"></span> 导出数据2
            </button>
        </div>
    </form>
    <script src="${pageContext.request.contextPath}/res/jquery-1.8.0.min.js"></script>
    <script src="${pageContext.request.contextPath}/res/bootstrap.min.js"></script>
    <script>
        function export_record(){


            var url = "export2?";

//            var year = $("#year").val();
//            var month = $("#month").val();
            url = url + $("#form").serialize();
//            url = url+"year="+year+"&month="+month;

            var a = document.createElement("a");
            a.setAttribute("href", url);
            a.setAttribute("target", "iframeXls");
            a.setAttribute("id", "openwin");
            document.body.appendChild(a);
//            layer.msg("已发送数据导出请求,请稍后...", {
//                icon : 7,
//                time : 1000
//            });
            a.click();

//        }else{
//            layer.msg("当前没有数据可以导出...", {
//                icon : 7,
//                time : 3000
//            });
        }

        function export1() {
            var url = "export?";
            var year = $("#year").val();
            var month = $("#month").val();
//            url = url + $("#form").serialize();
            url = url+"year="+year+"&month="+month;

            var a = document.createElement("a");
            a.setAttribute("href", url);
            a.setAttribute("target", "iframeXls");
            a.setAttribute("id", "openwin");
            document.body.appendChild(a);
//            layer.msg("已发送数据导出请求,请稍后...", {
//                icon : 7,
//                time : 1000
//            });
            a.click();
        }

    </script>
</body>
</html>
